import { getRoles, getRolesById } from "@/api/roles.js";
// 状态
const state = {
  RolesData: {},
  RolesDataById: {},
};
// 修改状态
const mutations = {
  setRolesData(state, payload) {
    state.RolesData = payload;
  },
  setRolesDataById(state, payload) {
    state.RolesDataById = payload;
  },
};
// 执行异步
const actions = {
  async getRoles(context) {
    const res = await getRoles();
    // console.log(res);
    context.commit("setRolesData", res);
  },
  async getRolesById(context, id) {
    console.log(id);
    const res = await getRolesById(id);
    console.log(res);
    context.commit("setRolesDataById", res);
  },
};
export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
